package com.nmgsr.ptmsapp.adapter;

import android.annotation.SuppressLint;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.nmgsr.beans.responsedao.PtmsToolRes;
import com.nmgsr.beans.responsedao.PtmsWarnScrapRes;
import com.nmgsr.ptmsapp.R;
import com.nmgsr.ptmsapp.utils.DateUtils;

public class ListPtmsWarnScrapAdapter extends BaseQuickAdapter<PtmsWarnScrapRes, BaseViewHolder> {
    public ListPtmsWarnScrapAdapter() {
        super(R.layout.list_ptms_wran_scrap_item);
    }

    @SuppressLint("ResourceAsColor")
    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, PtmsWarnScrapRes list) {
        baseViewHolder.setText(R.id.tv_name, list.getToolName());
        baseViewHolder.setText(R.id.tv_epc,"编号:"+ list.getToolNo());
        baseViewHolder.setText(R.id.tv_warnDays, "剩余天数：" + list.getWarnDays());
        baseViewHolder.setTextColor(R.id.tv_warnDays, 0xFFFF0000);

        try {
            String formattedScrapDate = DateUtils.formatDate(list.getScrapDate(), "yyyy-MM-dd", "yyyy年MM月dd日");
            baseViewHolder.setText(R.id.tv_scrapDate, "报废日期：" + formattedScrapDate);

        } catch (Exception e) {
            // 如果你字段可能为空，可以统一处理异常或默认值
            baseViewHolder.setText(R.id.tv_scrapDate, "日期格式错误");
        }
    }
}
